/* 
  保存路由跳转传递的参数
  1. 防止移动端刷新页面丢失参数, 所以这里的参数都会在 sessionStorage 保存一份
  2. 内容是原项目留下的示例代码, 可根据实际情况修改或者删除
*/

import { getSession, setSession } from '@/utils/sessionTool'

const state = {
  visitPatrolDetail: getSession('visitPatrolDetail') ? JSON.parse(getSession('visitPatrolDetail')) : {},
  visitPatrolLogDetail: getSession('visitPatrolLogDetail') ? JSON.parse(getSession('visitPatrolLogDetail')) : {},
  riskAssessmentDetail: getSession('riskAssessmentDetail') ? JSON.parse(getSession('riskAssessmentDetail')) : {},
  personReportDetail: getSession('personReportDetail') ? JSON.parse(getSession('personReportDetail')) : {}
}
const mutations = {
  setVisitPatrolDetail: (state, info) => {
    state.visitPatrolDetail = info
    setSession('visitPatrolDetail', JSON.stringify(info))
  },
  setVisitPatrolLogDetail: (state, info) => {
    state.visitPatrolLogDetail = info
    setSession('visitPatrolLogDetail', JSON.stringify(info))
  },
  setRiskAssessmentDetail: (state, info) => {
    state.riskAssessmentDetail = info
    setSession('riskAssessmentDetail', JSON.stringify(info))
  },
  setPersonReportDetail: (state, info) => {
    state.personReportDetail = info
    setSession('personReportDetail', JSON.stringify(info))
  }
}

const actions = {}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
